home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / mx / remoting / NetServices.as < prev    next >
Text File  |  2007-11-08  |  2KB  |  76 lines

  1. class mx.remoting.NetServices extends Object
  2. {
  3.    static var version = "1.2.0.124";
  4.    static var gatewayUrl = _root.gatewayUrl;
  5.    static var __sharedConnections = new Array();
  6.    function NetServices()
  7.    {
  8.       super();
  9.    }
  10.    static function setDefaultGatewayUrl(url)
  11.    {
  12.       mx.remoting.NetServices.defaultGatewayUrl = url;
  13.    }
  14.    static function setGatewayUrl(url)
  15.    {
  16.       mx.remoting.NetServices.gatewayUrl = url;
  17.    }
  18.    static function createGatewayConnection(url, infoLogger)
  19.    {
  20.       mx.remoting.NetServices.logger = infoLogger;
  21.       if(url == undefined)
  22.       {
  23.          url = mx.remoting.NetServices.gatewayUrl;
  24.          if(url == undefined)
  25.          {
  26.             url = mx.remoting.NetServices.defaultGatewayUrl;
  27.          }
  28.       }
  29.       if(url == undefined)
  30.       {
  31.          mx.remoting.NetServices.trace("NetServices","warning",4,"createGatewayConnection - gatewayUrl is undefined");
  32.          mx.remoting.NetServices.logger.logInfo("NetServices: createGatewayConnection - gateway url <" + url + "> is undefined",mx.services.Log.DEBUG);
  33.          return null;
  34.       }
  35.       var _loc2_ = new mx.remoting.Connection();
  36.       _loc2_.connect(url);
  37.       mx.remoting.NetServices.__sharedConnections[url] = _loc2_;
  38.       return _loc2_;
  39.    }
  40.    static function getConnection(uri)
  41.    {
  42.       return mx.remoting.NetServices.__sharedConnections[uri];
  43.    }
  44.    static function getHostUrl()
  45.    {
  46.       if(!mx.remoting.NetServices.isHttpUrl(_root._url))
  47.       {
  48.          mx.remoting.NetServices.trace("NetServices","warning",4,"createGatewayConnection - gatewayUrl is invalid");
  49.          return null;
  50.       }
  51.       var _loc2_ = _root._url.indexOf("/",8);
  52.       if(_loc2_ < 0)
  53.       {
  54.          mx.remoting.NetServices.trace("NetServices","warning",4,"createGatewayConnection - gatewayUrl is invalid");
  55.          return null;
  56.       }
  57.       return _root._url.substring(0,_loc2_);
  58.    }
  59.    static function isHttpUrl(url)
  60.    {
  61.       return url.indexOf("http://") == 0 || url.indexOf("https://") == 0;
  62.    }
  63.    static function getHttpUrl(url)
  64.    {
  65.       if(!mx.remoting.NetServices.isHttpUrl(url))
  66.       {
  67.          url = mx.remoting.NetServices.getHostUrl() + url;
  68.       }
  69.       return url;
  70.    }
  71.    static function trace(who, severity, number, message)
  72.    {
  73.       mx.remoting.NetServices.traceNetServices(who,severity,number,message);
  74.    }
  75. }
  76.